package org.hzz.sql;

import org.mybatis.dynamic.sql.SqlColumn;
import org.mybatis.dynamic.sql.SqlTable;
import org.mybatis.dynamic.sql.render.RenderingStrategies;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;

import java.sql.JDBCType;

import static org.mybatis.dynamic.sql.SqlBuilder.*;

/**
 * @author 胖卡
 * @version 1.0.0
 * @date 2024/7/21
 */
public class FirstTest extends SqlTable {
    public final SqlColumn<Integer> number1 = column("number1", JDBCType.INTEGER);
    public final SqlColumn<Integer> number2 = column("number2", JDBCType.INTEGER);
    protected FirstTest() {
        super("pkmer");
    }

    public static void main(String[] args) {
        FirstTest test = new FirstTest();
        test.test();
    }

    public void test(){
        SelectStatementProvider render = select(number1, number2)
                .from(new FirstTest())
                .where(number1, isLessThan(number2))
                .orderBy(number1, number2)
                .build()
                .render(RenderingStrategies.MYBATIS3);

        String selectStatement = render.getSelectStatement();
        System.out.println(selectStatement);


        SelectDSLCompleter completer = c ->
        {
            QueryExpressionDSL<org.mybatis.dynamic.sql.select.SelectModel>.QueryExpressionWhereBuilder or = c.where(number1, isEqualTo(1))
                    .or(number2, isNull());
            return or;
        };


    }
}
